package com.backstage.web;


import com.backstage.pojo.dto.Message;
import com.backstage.pojo.vo.ArticleVo;
import com.backstage.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ArticleController {

    @Autowired
    ArticleService articleService;
    @RequestMapping(value = "/article/getAll", method = RequestMethod.GET)
    public Message<List<ArticleVo>> getAllArticle(ArticleVo articleVo) {
        return articleService.getAllArticle(articleVo);
    }
    @RequestMapping(value = "/article/getArticleByid", method = RequestMethod.GET)
    public Message<ArticleVo> getArticleById(ArticleVo articleVo) {
        return articleService.getArticle(articleVo);
    }

    @RequestMapping(value = "/article/addArticle", method = RequestMethod.GET)
    public Message<String> addArticle(ArticleVo article) {
        return articleService.addArticle(article);
    }

    @RequestMapping(value = "/article/updateArticle", method = RequestMethod.GET)
    public Message<String> updateArticle(ArticleVo article) {
        return articleService.updateArticle(article);
    }

    @RequestMapping(value = "/article/deleteArticle", method = RequestMethod.GET)
    public Message<String> deleteArticle(Long id) {
        return articleService.deleteArticleById(id);
    }
    @RequestMapping(value = "/article/state", method = RequestMethod.GET)
   public Message<List<ArticleVo>> getState(ArticleVo articleVo){
        return articleService.getState(articleVo);
    }
}
